{extend name="admin/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/defau.css">
<script src="ADMIN_JS/art_dialog.source.js"></script>
<script src="ADMIN_JS/iframe_tools.source.js"></script>
<script src="ADMIN_JS/material_managedialog.js"></script>
{/block}
{block name="main"}
<div class="set-style"  >
	<dl>
		<dt>自动收货时间:</dt>
		<dd>
			<input id="order_auto_delinery" type="number" min="0.00" step="1.00" onkeyup="value=value.replace(/[^\d+(\.\d+)?]/g,'')" value="{$shopSet['order_auto_delinery']}" /> 
			<p class="hint">订单多长时间后自动收货，单位为/天(注：若为0，则默认14天自动收货)</p>
		</dd>
	</dl>
	
	<dl>
		<dt>订单自动关闭时间:</dt>
		<dd>
			<input id="order_buy_close_time" type="number" min="0.00" step="1.00" onkeyup="value=value.replace(/[^\d+(\.\d+)?]/g,'')" value="{$shopSet['order_buy_close_time']}" /> 
			<p class="hint">订单开始后多长时间未付款自动关闭，单位为/分钟(注：不填写或0默认关闭时间为60分钟)</p>
		</dd>
	</dl>
	<dl>
		<dt>是否开启余额支付</dt>
		<dd>
			<div class="controls">
				<label class="radio inline"><input type="radio" name="order_balance_pay" value="1" checked="checked" id="balanceResultYes">启用</label> 
				<label class="radio inline"><input type="radio" name="order_balance_pay" value="0" checked="checked" id="balanceResultNo">禁用</label>
				<input type="hidden" id="is_open" value="{$shopSet['order_balance_pay']}">
			</div>
			<p class="hint">是否启用余额支付</p>
		</dd>
	</dl>
	
	<dl>
		<dt>是否开启货到付款</dt>
		<dd>
			<div class="controls">
				<label class="radio inline"><input type="radio" name="order_delivery_pay" value="1"  id="payResultYes" {if condition="$shopSet['order_delivery_pay'] eq 1"}checked{/if}>启用</label> 
				<label class="radio inline"><input type="radio" name="order_delivery_pay" value="0"  id="payResultNo"  {if condition="$shopSet['order_delivery_pay'] eq 0"}checked{/if}>禁用</label>
			</div>
			<p class="hint">是否支持货到付款</p>
		</dd>
	</dl>
	
	
	<dl>
		<dt>订单完成时间:</dt>
		<dd>
			<p>
				<select id="order_delivery_complete_time">
					<option id = 'closeday0' value="0">&nbsp;&nbsp;立即</option>
					<option id = 'closeday1' value="1">&nbsp;&nbsp;1天</option>
					<option id = 'closeday2' value="2" >&nbsp;&nbsp;2天</option>
					<option id = 'closeday3' value="3" >&nbsp;&nbsp;3天</option>
					<option id = 'closeday4' value="4" >&nbsp;&nbsp;4天</option>
					<option id = 'closeday5' value="5" >&nbsp;&nbsp;5天</option>
					<option id = 'closeday6' value="6" >&nbsp;&nbsp;6天</option>
					<option id = 'closeday7' value="7" >&nbsp;&nbsp;7天</option>
  				</select>
			</p>
			<input type="hidden" id="closeday" value="{$shopSet['order_delivery_complete_time']}">
			<p class="hint">收货后，多少时间订单自动完成，单位为/天</p>
		</dd>
	</dl>	
	<dl>
		<dt>是否显示购买记录</dt>
		<dd>
			<div class="controls">
				<label class="radio inline"><input type="radio" name="order_show_buy_record" value="1" checked="checked" id="purchaseRecordYes">启用</label> 
				<label class="radio inline"><input type="radio" name="order_show_buy_record" value="0" checked="checked" id="purchaseRecordNo">禁用</label>
				<input type="hidden" id="or_open" value="{$shopSet['order_show_buy_record']}">
			</div>
			<p class="hint">是否显示购买记录</p>
		</dd>
	</dl>
	
	<dl>
		<dt>是否开启买家自提</dt>
		<dd>
			<div class="controls">
				<label class="radio inline"><input type="radio" name="buyer_self_lifting" value="1" checked="checked" id="sinceYes">启用</label> 
				<label class="radio inline"><input type="radio" name="buyer_self_lifting" value="0" id="sinceNo">禁用</label>
				<input type="hidden" id="is_start" value="{$shopSet['buyer_self_lifting']}">
			</div>
			<p class="hint">是否启用买家自提</p>
		</dd>
	</dl>
	
	<dl>
		<dt>是否开启商家配送</dt>
		<dd>
			<div class="controls">
				<label class="radio inline"><input type="radio" name="seller_dispatching" value="1" checked="checked" id="dispatchingYes">启用</label> 
				<label class="radio inline"><input type="radio" name="seller_dispatching" value="0" id="dispatchingNo">禁用</label>
				<input type="hidden" id="is_dispatching" value="{$shopSet['seller_dispatching']}">
			</div>
			<p class="hint">是否启用商家配送</p>
		</dd>
	</dl>
	<dl>
		<dt>购物返积分设置:</dt>
		<dd>
			<p>
				<select id="shopping_back_points">
					<option  value="1" {if condition="$shopSet['shopping_back_points'] eq 1"}selected{/if}>&nbsp;&nbsp;订单已完成</option>
					<option  value="2" {if condition="$shopSet['shopping_back_points'] eq 2"}selected{/if}>&nbsp;&nbsp;已收货</option>
					<option  value="3" {if condition="$shopSet['shopping_back_points'] eq 3"}selected{/if}>&nbsp;&nbsp;支付完成</option>
  				</select>
			</p>
			<p class="hint">购物返积分设置</p>
		</dd>
	</dl>	
	<dl>
		<dt>发票税率:</dt>
		<dd>
			<input id="order_invoice_tax" type="number" min="0.00" step="0.01" value="{$shopSet['order_invoice_tax']}" />
			<p class="hint">设置开发票的税率，单位为%</p>
		</dd>
	</dl>
	<dl>
		<dt>发票内容:</dt>
		<dd>
			<textarea  rows="2" id="order_invoice_content"
				class="textarea w400" maxlength="50">{$shopSet['order_invoice_content']}</textarea>
			<p class="hint">客户要求开发票时可以选择的内容，逗号分格代表一个选项，例如：办公用品,明细</p>
		</dd>
	</dl>
	<button class="edit_button" onclick="setConfigAjax();">提交</button>
</div>
<script src="ADMIN_JS/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>

var validation = true;//验证余额输入
$("#order_invoice_tax").live("keyup",function(){
	var reg = /^\d+(.{0,1})(\d{0,2})$/;
	if(!reg.test($(this).val())){
		showTip("请输入大于0的数字，并且保留两位小数","warning");
		validation = false;
	}else{
		validation = true;
	}
})
	window.onload=function(){
		var is_open = $("#is_open").val();
		if(is_open == ''){
			is_open = 0;
		}
		if(parseInt(is_open) == 0){
			$("#balanceResultNo").prop("checked","checked");
		}else{
			$("#balanceResultYes").prop("checked","checked");
		}
		
		var or_open = $("#or_open").val();
		if(or_open == ''){
			or_open = 0;
		}
		//alert(or_open);
		if(parseInt(or_open) == 0){
			$("purchaseRecordNo").prop("checked","checked");
		}else{
			$("#purchaseRecordYes").prop("checked","checked");
		}
		
		var closeday = $("#closeday").val();
		//alert(closeday);
		$("#closeday"+closeday).attr("selected", true);
		
		var is_start = $("#is_start").val();
		if(is_start == ''){
			is_start = 0;
		}
		if(parseInt(is_start) == 0){
			$("#sinceNo").prop("checked","checked");
		}else{
			$("#sinceYes").prop("checked","checked");
		}
		
		var is_dispatching = $("#is_dispatching").val();
		if(is_dispatching == ''){
			is_dispatching = 0;
		}
		if(parseInt(is_dispatching) == 0){
			$("#dispatchingNo").prop("checked","checked");
		}else{
			$("#dispatchingYes").prop("checked","checked");
		}
		
	};
	function setConfigAjax(){
		var order_delivery_complete_time = $('#order_delivery_complete_time').val();
		var order_buy_close_time = $('#order_buy_close_time').val();
		var order_balance_pay = $("input[type='radio'][name='order_balance_pay']:checked").val();
		var order_delivery_pay = $("input[type='radio'][name='order_delivery_pay']:checked").val();
		var order_auto_delinery = $("#order_auto_delinery").val();
		var order_show_buy_record = $("input[type='radio'][name='order_show_buy_record']:checked").val();
		var buyer_self_lifting = $("input[type='radio'][name='buyer_self_lifting']:checked").val();
		var seller_dispatching = $("input[type='radio'][name='seller_dispatching']:checked").val();
		var order_invoice_tax = $("#order_invoice_tax").val();
		var order_invoice_content = $("#order_invoice_content").val();
		var shopping_back_points = $("#shopping_back_points").val();
		if(validation){
			$.ajax({
				type:"post",
				url : "ADMIN_MAIN/config/shopset",
				data : {
					"order_delivery_complete_time" : order_delivery_complete_time,
					"order_buy_close_time":order_buy_close_time,
					"order_balance_pay" : order_balance_pay,
					"order_delivery_pay" : order_delivery_pay,
					"order_auto_delinery" : order_auto_delinery,
					"order_show_buy_record" : order_show_buy_record,
					"buyer_self_lifting" : buyer_self_lifting,
					"seller_dispatching" : seller_dispatching,
					"order_invoice_tax" : order_invoice_tax,
					"order_invoice_content" : order_invoice_content,
					"shopping_back_points" : shopping_back_points
				},
				success : function(data){
					if(data['code'] > 0)
						{
							showMessage('success', data["message"]);
							location.href="ADMIN_MAIN/config/shopset";
						}else{
							showMessage('error', data["message"]);
						}
				}
			});
		}else{

			showTip("请输入大于0的数字，并且保留两位小数","warning");
		}
		
	}
</script>
{/block}